package com.addremoveitemtest;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class ItemFragment extends Fragment {

    @BindView(R.id.textCur)
    TextView textCur;
    Unbinder unbinder;

    /*public ItemFragment(String str) {
        this.str = str;
        textCur.setText(str);
    }
*/
    public static ItemFragment newInstance(String str){
        ItemFragment itemFragment=new ItemFragment();
        Bundle bundle=new Bundle();
        bundle.putString("str",str);
        itemFragment.setArguments(bundle);
        return itemFragment;
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_item_fragment, container, false);
        unbinder = ButterKnife.bind(this, view);
        Bundle arguments = getArguments();
        if (arguments != null) {

            String str = arguments.getString("str");
            textCur.setText(str);
        }
        return view;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();

    }
}
